package common;

import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;

public class DateUtils {
	  public static final String FULL_DATE_FORMAT = "dd-MM-yyyy HH:mm:ss";
	

	  public static Date getNow(){
		  Calendar currentDate = Calendar.getInstance();
	   	  return new Date(currentDate.getTimeInMillis());
	  }

	  public static Date convertStringToDate(String stringDate , String format){
		 
		  SimpleDateFormat dateFormat = new SimpleDateFormat(format,Locale.ENGLISH);
		  ParsePosition pos = new ParsePosition(0);
		  Date date = dateFormat.parse(stringDate,pos);
	      return date;
	  }
	  
	  public static String convertDateTostring(Date date ,String format){
		  SimpleDateFormat dateFormat = new SimpleDateFormat(format);
	 		String dateString = dateFormat.format(date);
	 		return dateString;
	  }
	  
	  public  static boolean isAfterDate(Date selectedDate , Date comparedDate){


		   boolean isAfter = false;
		   Calendar selectedDateCalender = Calendar.getInstance();
		   Calendar comparedDateCalender = Calendar.getInstance();
		   selectedDateCalender.setTime(selectedDate);
		   comparedDateCalender.setTime(comparedDate);
		   isAfter = selectedDateCalender.after(comparedDateCalender);
		   return isAfter;
	  }
	  
	  public  static boolean isBeforeDate(Date selectedDate , Date comparedDate){
		  
		  /*
		   * ??
		   * return selectedDate.before(comparedDate);
		   */
		   boolean isBefore = false;
		   Calendar selectedDateCalender = Calendar.getInstance();
		   Calendar comparedDateCalender = Calendar.getInstance();
		   selectedDateCalender.setTime(selectedDate);
		   comparedDateCalender.setTime(comparedDate);
		   isBefore = selectedDateCalender.before(comparedDateCalender);
		   return isBefore;
	  }
	  
    public static Date convertDateToStringWithDateFormat(String date ,String  stringFormat){
    	return null;
    }
	
}
